use AppleShop
go
insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
	values('iPad 1 8GB','iPad1','iPad',120,'~/IMG/iPad/iPad1/ipad_1_8GB.jpg')
insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
	values('iPad 1 32GB','iPad1','iPad',180,'~/IMG/iPad/iPad1/ipad_1_32_GB.jpg')
insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
	values('iPad 2 8GB','iPad2','iPad',220,'~/IMG/iPad/iPad2/ipad2.jpg')
insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
	values('iPad 2 32GB','iPad2','iPad',280,'~/IMG/iPad/iPad2/ipad2-big(1).jpg')
insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
	values('iPad 3 8GB','iPad3','iPad',420,'~/IMG/iPad/iPad3/retina_nohires.jpg')
insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
	values('iPad 3 32GB','iPad3','iPad',480,'~/IMG/iPad/iPad3/retina_nohires.jpg')

-- insert
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 8GB','~/IMG/iPad/iPad1/ipad_1_8GB.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 8GB','~/IMG/iPad/iPad1/ipad_1_32_GB.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 8GB','~/IMG/iPad/iPad1/wallpaper-1269656.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 8GB','~/IMG/iPad/iPad1/wallpaper-1722588.jpg','...')

insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 32GB','~/IMG/iPad/iPad2/apple-ipad-2-16gb-wifi.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 32GB','~/IMG/iPad/iPad2/ipad_2_hero_back.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 32GB','~/IMG/iPad/iPad2/ipad_2_hero_front.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 32GB','~/IMG/iPad/iPad2/ipad2 (1).jpg','...')

insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 32GB','~/IMG/iPad/iPad1/ipad_1_8GB.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 32GB','~/IMG/iPad/iPad1/ipad_1_32_GB.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 32GB','~/IMG/iPad/iPad1/wallpaper-1269656.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 1 32GB','~/IMG/iPad/iPad1/wallpaper-1722588.jpg','...')

insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 8GB','~/IMG/iPad/iPad2/ipad2.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 8GB','~/IMG/iPad/iPad2/ipad2-big(1).jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 8GB','~/IMG/iPad/iPad2/ipad_2_hero_front.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 2 8GB','~/IMG/iPad/iPad2/ipad2 (1).jpg','...')

insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 8GB','~/IMG/iPad/iPad3/appstore.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 8GB','~/IMG/iPad/iPad3/retina_nohires.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 8GB','~/IMG/iPad/iPad3/airplay_bg2_nohires.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 8GB','~/IMG/iPad/iPad3/maps.jpg','...')

insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 32GB','~/IMG/iPad/iPad3/maps.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 32GB','~/IMG/iPad/iPad3/siri.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 32GB','~/IMG/iPad/iPad3/smartcover_045.jpg','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('iPad 3 32GB','~/IMG/iPad/iPad3/wireless_bg_nohires.jpg','...')

-- procedure 1
go
create procedure spGetProduct_iPad
as
	begin
		select * from Product where ProductsID like '%iPad%'
	end
go
-- procedure 2
create procedure spGetProduct_iPadDetails
@ID varchar(50)
as
	begin
		select * from ProductDetails where DetailsID = @ID
	end

go
-- procedure 3
create procedure spInsert_iPad
@ProductsID varchar(50),
@ProductsName varchar(50) ,
@ProductsTypeName varchar(50) ,
@ProductsPrice float,
@ProductsImage varchar(200) 
as
	begin
		insert into Product(ProductsID,ProductsName,ProductsTypeName,ProductsPrice,ProductsImage) values(@ProductsID,@ProductsName,@ProductsTypeName,@ProductsPrice,@ProductsImage);
	end
go

-- procedure 4
create procedure spInsert_iPadDetails
@DetailsID varchar(50) ,
@DetailsImage varchar(200) ,
@DetailsText varchar(500) 
as
	begin
		insert into ProductDetails(DetailsID, DetailsImage, DetailsText) 
		values (@DetailsID, @DetailsImage, @DetailsText);
	end
go

-- procedure 5
create procedure spGetAllProductDetail_Ipad
as
	begin
		select * from ProductDetails where DetailsID like '%iPad%'
	end
go
-- procedure 6
create procedure spGetProductiPad_Update
@idProduct nvarchar (50)
as
	begin
		select * from Product where ProductsID = @idProduct
	end
go

-- procedure 7
create procedure spUpdateProduct_iPad
@ID varchar(50),
@Name varchar(50),
@Price float,
@Image varchar(200)
as
	begin
		UPDATE Product SET ProductsName = @Name,ProductsPrice = @Price, ProductsImage = @Image Where ProductsID = @ID
	end
go

-- procedure 8
create procedure spUpdateProductiPadDetails
@No int,
@Image varchar(200) ,
@Text varchar(500)
as
	begin
		Update ProductDetails SET DetailsImage = @Image, DetailsText = @Text Where DetailsNo = @No
	end
go

-- procedure 9
create procedure spGetProductiPadDetailsByNo
@No int
as
	begin
		select * from ProductDetails where DetailsNo = @No
	end
go
-- procedure 10
create procedure spGetProductiPadDetailsNoByDetaisID
@detailID varchar(50)
as
	begin
		select * from ProductDetails where DetailsID = @detailID
	end
go
-- procedure 11
create procedure spDeleteIpad
@ID varchar(50)
as
	begin
		Delete From Product Where ProductsID = @ID
	end
-- procedure 12	
go
create procedure spDeleteIPadDetails
@No int
as
	begin
		Delete From ProductDetails Where DetailsNo = @No
	end